<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>时钟</title>
	</head>
	<!--页面的注释-->
	<!--body有个onload事件，在dom树构建完毕后触发-->
	<body onload="setInterval(getDateTime,1000)">
		<div id="enclock"></div>
		<div id="cnclock"></div>
	</body>
	<script>
		function getDateTime(){
			//获取当前系统时间
			var date=new Date();
			
			//获取页面上div
				var enclock = document.getElementById("enclock")
				enclock.innerHTML="<font color='red'>"+ date+"</font>";
				var cncolck=document.getElementById('cncolck');
				var year=date.getFullYear();
				var month=date.getMonth()+1;
				var day =date.getDate();
				
				var hour=date.getHours();
				var minute=date.getMinutes();
				var second=date.getSeconds();
				
				cnclock.innerText= year +"年" +month +"月" + day +"日"
				+ hour + "时" + minute + "分 "+ second + "秒" ;
			
		}
	</script>
</html>
